<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>王方超</title>
    <style>
        body {
            height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #f38181; /* 背景色 */
            font-family: Arial, sans-serif;
        }
        .container {
            text-align: center;
            padding: 20px;
            border-radius: 10px;
            background-color: rgba(255, 255, 255, 0.2);
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        }
        #myCanvas {
            display: block;
            margin-top: 20px;
        }
        input[type="number"] {
            padding: 10px;
            font-size: 18px;
            border: 2px solid #3498db;
            border-radius: 5px;
            margin-right: 10px;
            width: 150px;
            text-align: center;
        }
        button {
            padding: 10px 20px;
            font-size: 18px;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #2980b9;
        }
    </style>
</head>
<body>
    <div class="container">
        <input type="number" id="speedMultiplier" placeholder="填个数">
        <button onclick="startDrawing()">试一下</button>
        <canvas id="myCanvas" width="600" height="600"></canvas>
    </div>

    <script>
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        
        var centerX = 300;
        var centerY = 300;
        var radius = 300; // 增大圆的半径
        
        // 初始角度，单位为弧度
        var angle1 = 0;
        var angle2 = 0;
        
        // 速度，单位为弧度每秒
        var speed1 = Math.PI / 30; // 6度每秒
        var speed2 = speed1; // 速度倍数初始化为1

        function getSpeedMultiplier() {
            var multiplier = document.getElementById("speedMultiplier").value;
            return parseFloat(multiplier) || 1; // 如果输入无效，默认为1
        }

        function startDrawing() {
            speed2 = speed1 * getSpeedMultiplier(); // 根据用户输入设置速度

            // 绘制圆
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            ctx.beginPath();
            ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
            ctx.strokeStyle = "#95e1d3"; // 圆的颜色
            ctx.lineWidth = 3;
            ctx.stroke();

            setInterval(draw, 300); // 每200ms更新一次
        }

        function draw() {
            // 计算两个点的位置
            var point1 = {
                x: centerX + radius * Math.cos(angle1),
                y: centerY + radius * Math.sin(angle1)
            };
            var point2 = {
                x: centerX + radius * Math.cos(angle2),
                y: centerY + radius * Math.sin(angle2)
            };
            
            // 绘制连线
            ctx.beginPath();
            ctx.moveTo(point1.x, point1.y);
            ctx.lineTo(point2.x, point2.y);
            ctx.strokeStyle = "#eaffd0"; // 线段的颜色
            ctx.lineWidth = 2;
            ctx.stroke();
            
            // 更新角度
            angle1 += speed1;
            angle2 += speed2;
        }
    </script>
</body>
</html>
